﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BOMS.Lib;
using BOMS.DBUtility;
using System.Threading;

namespace BOMSDataTransportForMySqlService
{
    class Program
    {
        static void Main(string[] args)
        {
            int transTime=Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DataTransportTime"]);
            int start = DateTime.Now.Minute;
            Console.WriteLine("start Time:" + DateTime.Now.ToString());
           // while(true)
            {
          //  while ((DateTime.Now.Second-start) >= transTime)
            {       
                start = DateTime.Now.Minute;
                try
                {
                    string DBType = System.Configuration.ConfigurationManager.AppSettings["DBType"];
                    string strSql = "";
                    if (DBType == "MySql")
                    {
                        strSql = " call sp_sub_SnapshotAndSaveLogData_grp ; call sp_sub_SnapshotAndSaveLogData ";
                    }
                    else if (DBType == "MsSql")
                    {
                        strSql = " exec sp_sub_SnapshotAndSaveLogData_grp ; exec sp_sub_SnapshotAndSaveLogData ";
                    }
                    DbHelper.ExecuteSql(strSql);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error message:" + ex.Message);
                    Log lg = new Log();
                    lg.log(ex);
                }
                Console.WriteLine("Transport success.");
                Thread.Sleep(60000 * transTime);
            }
        }
   
        }
    }
}
